#引入包
import numpy as np
import sys

# 检查Python和NumPy版本
print(f"Python版本: {sys.version}")
print(f"NumPy版本: {np.__version__}")


'''
arr1 = np.array([1, 2, 3])
arr2 = np.array([[4, 5, 6],
                [7, 8, 9],[3,5,8]])

print(arr1)
print(arr2)

# 创建一个2x4的数组
arr0 = np.zeros((2, 4))
print(arr0)

arr3 =  np.ones((3, 2))
print(arr3)

arr4 = np.full((5, 2), 10)
print(arr4)
# 创建等差数列数组
range_arr = np.arange(0,10,2)
print(range_arr)

# 创建单位矩阵
identity_matrix = np.eye(3)
print(f"单位矩阵:\n{identity_matrix}")'''


'''arr5 = np.array([[1, 2,3,4], [3, 4,5,6]])
print(f"数组: \n{arr5}")
print(f"数组维度: {arr5.ndim}")
print(f"数组形状: {arr5.shape}")
print(f"数组大小: {arr5.size}")
print(f"数据类型: {arr5.dtype}")
print(f"每个元素字节大小: {arr5.itemsize}")
print(f"总字节大小: {arr5.nbytes}")'''

'''arr = np.array([['张三', '北京', '99', '98', '96'],
                 ['李四', '山海', '99', '98', '96'],
                 ['王五', '深圳', '99', '98', '96']])
print(arr[2])

print(arr[1:3])

print(arr[1][3])

print(arr[:,0])
print(arr[:,0:3])
print(f"第一列: {arr[:, 0]}")
print(f"子数组:\n{arr[0:2, 1:3]}")


# 布尔索引
arr = np.array([1, 2, 3, 4, 5, 6])
# 得到一个数组，存放的都是布尔数值，长度与原来的长度一致
bool_mask = arr > 3
print(f"布尔掩码: {bool_mask}")
print(f"条件筛选: {arr[bool_mask]}")

# 花式索引
arr2d = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
print(f"选择特定行: {arr2d[[0, 2]]}")
print(f"选择特定行列: {arr2d[[0, 2], [0, 1]]}")'''



'''arr21 = np.array([['张三', '北京', '99', '98', '96'],
                 ['李四', '山海', '99', '98', '96'],
                 ['王五', '深圳', '99', '98', '96']])
print(f"选择特定行: {arr21[[0, 2]]}")
print(f"选择特定行列: {arr21[[0, 2], [0, 1]]}")'''


